import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import { Attribute } from './attribute.entity';
import { Specification } from './specification.entity';
import { IsOptional } from 'class-validator';
import { Goods } from './goods.entity';

@Entity()
export class GoodsSpecification {
  @PrimaryGeneratedColumn()
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', nullable: false})
  goods_id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', nullable: false})
  specification_id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar',length: 50})
  value: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar',length: 255})
  pic_url: string;

  @ManyToOne(type => Specification,specification => specification.goodsSpecification)
  @JoinColumn({
    name:"specification_id"
  })
  specification: Specification;

  @ManyToOne(type => Goods,goods => goods.goodsSpecification)
  @JoinColumn({
    name:"goods_id"
  })
  goods: Goods;

}
